package com.eduask.dao.impl;

import java.util.List;

import org.springframework.stereotype.Repository;

import com.eduask.beans.Messages;
import com.eduask.dao.MessagesDAO;
import com.eduask.util.HibernateUtil;

@Repository
public class MessagesDAOImpl extends HibernateUtil implements MessagesDAO{

	@Override
	public void saveMessages(Messages messages) {
		getSession().save(messages);
	}

	@Override
	public void removeMessages(Messages messages) {
		getSession().delete(messages);
	}

	@Override
	public Messages findMessagesById(Integer id) {

		return getSession().get(Messages.class, id);
	}

	@Override
	public List<Messages> findAllMessagess() {
		String hql = "from Messages messages order by messages.id asc";
		return getSession().createQuery(hql).list();
	}

}
